package com.wd.mvp.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.wd.base.ui.BaseFragment;
import com.wd.base.util.ViewUtils;
import com.wd.mvp.R;
import com.wd.mvp.presenter.DemoPresenterImpl;
import com.wd.mvp.presenter.IDemoPresenter;
import com.wd.mvp.view.IDemoView;

/**
 * NA<BR>
 *
 * @author w4425
 * @version [V2.0.0, 2021/3/17]
 * @since V2.0.0
 */
public class DomeFragment extends BaseFragment implements IDemoView {
    private TextView tv_text;
    private IDemoPresenter presenter;

    /**
     * 获取MainFragment实例对象
     *
     * @return MainFragment
     */
    public static DomeFragment newInstance() {
        return new DomeFragment();
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        presenter = new DemoPresenterImpl(this);
    }

    @Override
    protected String getLogTag() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_play;
    }

    @Override
    protected void initView(View view) {
        tv_text = ViewUtils.findViewById(view, R.id.tv_text);
        if (presenter != null) {
            presenter.textDemo("0001");
        }
    }

    @Override
    public void showSuccess(String msg) {
        tv_text.setText(msg);
    }

    @Override
    public void fail(String msg) {
        tv_text.setText("Error");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (presenter != null) {
            presenter.onDestroy();
        }
    }
}
